#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int T, n, m, a, b, c;
const int N = 510;
int x[N][N];
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin >> T;
    while (T--) {
        cin >> n;
        ll ans = 0;
        for (int i = 1;i <= n * 2;i++) {
            for (int j = 1;j <= n * 2;j++) {
                cin >> x[i][j];
                if (i > n && j > n) {
                    ans += x[i][j];
                }
            }
        }
        ans += min(min({ x[n + 1][1],x[2 * n][1],x[n + 1][n],x[2 * n][n] }), min({ x[1][n + 1],x[1][2 * n],x[n][n + 1],x[n][2 * n] }));
        cout << ans << endl;
    }
    return 0;
}
